/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package percussiongenerator.commands;

import java.util.ArrayList;
import java.util.Collection;
import org.jfonia.connect5.intervals.Interval;
import org.jfonia.connect5.intervals.LinkedDoubleIntervalList;
import org.jfonia.connect5.intervals.LinkedIntIntervalList;
import org.jfonia.connect5.intervals.LinkedLongIntervalList;

/**
 *
 * @author Jannes Plyson
 */
public class AddMultipleIntervals implements ICommand{
    private ArrayList<AddInterval> commands = new ArrayList<AddInterval>();;

    public AddMultipleIntervals(Collection<Interval> intervals, LinkedIntIntervalList list){        
        for(Interval interval : intervals){
            commands.add(new AddInterval(interval, list));
        }
    }

    public AddMultipleIntervals(Collection<Interval> intervals, LinkedLongIntervalList list){
        for(Interval interval : intervals){
            commands.add(new AddInterval(interval, list));
        }
    }

    public AddMultipleIntervals(Collection<Interval> intervals, LinkedDoubleIntervalList list){
        for(Interval interval : intervals){
            commands.add(new AddInterval(interval, list));
        }
    }

    public void execute() {
        for(AddInterval command : commands){
            command.execute();
        }
    }

    public void undo() {
        for(AddInterval command : commands){
            command.undo();
        }
    }
}
